import swaggerJSDoc from 'swagger-jsdoc';
import { authDocs } from '../docs/auth.doc';
import { userDocs } from '../docs/user.doc';
import { publicDocs } from '../docs/public.doc';
import { friendDocs } from '../docs/friend.doc';

const SwaggerOptions = {
  definition: {
    openapi: '3.0.0',
    info: {
      title: 'User 文档',
      version: '1.0.0',
      description: '一个简单的 Express API 文档示例',
    },
    servers: [
      {
        url: process.env.API_BASE_URL || 'http://localhost:3000',
      },
    ],
    paths: {
      '/auth/login': authDocs.login,
      '/auth/register': authDocs.register,
      '/users/get': userDocs.get,
      '/users/update': userDocs.update,
      '/users/update/password': userDocs.updatePassword,
      '/apis/code': publicDocs.code,
      '/apis/upload': publicDocs.upload,
      '/friend/list': friendDocs.getList
    }
  },
  apis: [], // 不再从路由文件读取注释
};

const SwaggerSpec = swaggerJSDoc(SwaggerOptions);

export default SwaggerSpec;
